<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="/js/libs/axios.js"></script>
    <script src="/js/libs/vue.js"></script>
    <script src="/js/libs/jq3.6.js"></script>

    <link href="/css/libs/bootstarp@5.1.3_min.css" rel="stylesheet"
          crossorigin="anonymous">
    <link rel="stylesheet" href="/css/libs/http_cdn.jsdelivr.net_npm_bootstrap@4.6.2_dist_css_bootstrap.css"
          crossorigin="anonymous">
    <link rel="stylesheet" href="/css/main.css">

    <title>Bot代挂-配置中心</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light tm-0">
    <a class="navbar-brand" href="/">
        <img style="opacity: 0.86;max-width: 50px; border-radius: 999px"
             class="navbar-brand" src="/icon" alt="qq"></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
            aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="/">QQ代挂 <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="http://kloping.top/">kloping's</a>
            </li>
            <li class="nav-item">
                <a class="nav-link disabled">更多功能;敬请期待.</a>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <a class="dropdown-item" target="_blank" href="https://github.com/gdpl2112/dg-bot">
                <img style="opacity: 0.86;max-width: 35px" alt="github" loading="lazy"
                     src="https://s.nmxc.ltd/sakurairo_vision/@2.6/display_icon/sora/github.png">
                github 开源地址
            </a>
        </form>
    </div>
</nav>

<center style="margin-top: 50px;color: rgba(33,151,252,0.95);"><h1> Bot代挂 配置中心 </h1></center>
<div class="container" id="main">
    <div class="row justify-content-center">
        <div class="col">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">回复cd(单位/秒):</span>
                </div>
                <input id="cd0" type="number" min="1" class="form-control">
                <div class="input-group-append">
                    <button v-on:click="modify('cd0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">复述前置:</span>
                </div>
                <input id="retell" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('retell')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">回复开启:</span>
                </div>
                <input id="open0" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('open0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">回复关闭:</span>
                </div>
                <input id="close0" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('close0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">监听开启:</span>
                </div>
                <input id="open1" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('open1')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">监听关闭:</span>
                </div>
                <input id="close1" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('close1')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">回复添加:</span>
                </div>
                <input id="add0" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('add0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">取消添加回复:</span>
                </div>
                <input id="cancel0" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('cancel0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">查询回复:</span>
                </div>
                <input id="select0" type="text" class="form-control" aria-label="">
                <div class="input-group-append">
                    <button v-on:click="modify('select0')" type="button" class="btn btn-outline-primary">修改</button>
                </div>
            </div>
            <hr>

            <div class="alert alert-info text-center" role="alert">
                自定义脚本
            </div>
            <button v-on:click="codePost('code')" type="button"
                    class="btn btn-primary btn-lg btn-block">修改
            </button>
            <button v-on:click="getException()" type="button"
                    class="btn btn-primary btn-lg btn-block">获取报错
            </button>

            <hr>
            <div class="input-group">
                <textarea style="height: 240px" id="code" class="form-control" aria-label="js 脚本"
                          placeholder="java script 自定义脚本">

                </textarea>
            </div>
        </div>
    </div>
</div>
<br>
<br>
<hr>
<br>
<br>
<div class="modal fade" id="modal-a" tabindex="-1" aria-labelledby="moda-label" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="moda-label">添加一个API</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="关闭"></button>
            </div>
            <div class="modal-body text-danger">
                <samp id="modal-body">

                </samp>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" data-bs-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<br>
<br>
<script src="/js/utils.js"></script>
<script>
    let vm1 = new Vue({
        el: "#main",
        created: function () {
            axios.get("/config",).then(function (response) {
                let keys = Object.keys(response.data);
                for (let i = 0; i < keys.length; i++) {
                    let key = keys[i];
                    let value = response.data[key]
                    $("#" + key).val(value)
                }
            }).catch(function (err) {
                alert(err);
            })
        }, data: {}, methods: {
            modify: function (id) {
                let key = id;
                let value = $("#" + id).val()
                axios.get("/conf-modify?key=" + key + "&value=" + value).then(function (response) {
                    alert(response.data)
                }).catch(function (err) {
                    alert(err);
                })
            }, codePost: function (id) {
                let value = $("#" + id).val()
                let df = new FormData()
                df.set("code", value)
                axios.post("/code-modify", df).then(function (response) {
                    alert(response.data)
                }).catch(function (err) {
                    alert(err);
                })
            }, getException: function () {
                axios.get("/get-exception").then(function (response) {
                    $("#moda-label").html("时间: " + formatMsgTime(response.data.time))
                    $("#modal-body").html(response.data.msg.replaceAll("\r\n","<br>").replaceAll("\t","&nbsp;&nbsp;"))
                    $('#modal-a').modal('show')
                }).catch(function (err) {
                    alert(err);
                })
            }
        }
    });
</script>
<script src="/js/libs/http_cdn.jsdelivr.net_npm_jquery@3.5.1_dist_jquery.slim.min.js" crossorigin="anonymous"></script>
<script src="/js/libs/http_cdn.jsdelivr.net_npm_bootstrap@4.6.2_dist_js_bootstrap.bundle.js"
        crossorigin="anonymous"></script>
<script src="/js/libs/http_cdn.jsdelivr.net_npm_bootstrap@5.1.3_dist_js_bootstrap.bundle.js"
        crossorigin="anonymous"></script>
</body>
</html>